

if(request.method!=='POST'){

		response.redirect("/home",request,response);
	    response.end();

}else{


	

	var title=request.parameters["title"];
	var category=request.parameters["category"];
	var boardname=title;
	var session=request.getSession();
	
	if(typeof session==='undefined'){


		var output = {redirect: "/login",msg:"not good"};
	
		response.headers["Content-Type"]="application/json";	
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();
	
	}else if(!session.LoggedIn){
		var output = {redirect: "/login",msg:"not good"};
	
		response.headers["Content-Type"]="application/json";	
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();

	}else{

	var user=session.user;

	

	var boardController=request.require("./boardController");
	boardController.setBoard(title,category,boardname,user.username,response,cb);
	}
}

function cb(boardName,msg,response){

	
	if(boardName){
	
		var url="/board?name="+boardName;
		var output = {redirect:url ,msg:undefined};
	
		response.headers["Content-Type"]="application/json";
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();
		
	}else{
	
	var output = {redirect: "/home",msg:"not good"};
	
		response.headers["Content-Type"]="application/json";	
		response.headers["Access-Control-Allow-Origin"]="*";
		response.body="";
		response.body+=JSON.stringify(output);
		response.end();
	}
	
	
}



